<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>电影列表</title>
    <%- include common  %>
</head>
<body>
    <%- include("head",{title:"movie",username}) %>
    <div class="container-fluid">
        <div class="container">
            <h4 class="text-primary h3"> 电影列表 </h4>
            <div class="row">
                <div class="col-md-6 col-sm-6 col-xs-12">
                    <button class="btn btn-primary" onclick="location.href='/movie?year=1'">
                        年份升序
                    </button>
                    <button class="btn btn-info"  onclick="location.href='/movie?year=-1'">
                        年份降序
                    </button>
                    <button class="btn btn-danger"  onclick="location.href='/movie?rating.average=1'">
                        评分升序
                    </button>
                    <button class="btn btn-warning" onclick="location.href='/movie?rating.average=-1'">
                        评分降序
                    </button>
                </div>
            </div>
            <div class="row" style="margin-top:10px;">
                <div class="col-md-3 col-sm-6 col-xs-12">
                    <div class="form-group" style="display: flex">
                        <input type="text"  id="keyword"    class="form-control"  placeholder="Enter Keyword">
                        <button class="btn btn-danger"  onclick="searchDone()">
                            电影搜索
                        </button>
                    </div>
                </div>
            </div>
            <div class="row" style="margin-top:10px;">
            <%    if(result.length>0){   %>
                <%    result.forEach((item,index)=>{    %>
                        <div class="col-md-3 col-sm-6 col-xs-12">
                            <a href="/comment/mdetail?mid=<%- item.id %>">
                                <div class="thumbnail" style="cursor: pointer;">
                                    <img style="height:240px;width:100%;" src="<%- item.images.large.replace(/img7/,'img3') %>"  alt="">
                                    <div>
                                        <p class="text-primary"> <%- item.title  %></p>
                                        <p class="text-info">年份: <%- item.year  %></p>
                                        <p class="text-danger">评分: <%- item.rating.average  %></p>
                                        <p class="text-warning">分类: <%- item.genres  %></p>
                                    </div>
                                </div>
                            </a>
                        </div>
                <%    })  %>
            <%    }else{   %>
                    <p class="text-center text-danger">暂无电影数据</p>
            <%    }   %>
            </div>
        </div>
    </div>

    <script>
    function searchDone(){
        location.href = "/movie?keyword="+$("#keyword").val()
    }
    </script>

    <%- include foot %>
</body>
</html>